#pragma once

#include <gexpl_timer_event.h>
#include <gofcl_timer_intf.h>

typedef struct {
	timer_event_expl_s interrupt;
	timer_event_expl_s over_interrupt;
} __attribute__((aligned(2))) timer_intf_expl_s;

_Static_assert(sizeof(timer_intf_expl_s) == 2,
	       "Struct timer_intf_expl_s defined error!");

static inline void timer_set_int_flag(timer_qe timer_q, timer_intf_expl_s flag) {
	union {
		timer_intf_expl_s e;
		timer_intf_s i;
	} ei = {
		.e = flag,
	};
	timer_wreg_intf_s(timer_q, ei.i);
}

static inline timer_intf_expl_s timer_get_int_flag(timer_qe timer_q) {
	union {
		timer_intf_expl_s e;
		timer_intf_s i;
	} ei = {
		.i = timer_rreg_intf_s(timer_q),
	};
	return ei.e;
}
